<%@ page language="java" contentType="text/html; charset=utf-8" %>
<%@ page import="cn.hutool.crypto.digest.DigestUtil" %>
<%@ page import="com.alibaba.fastjson.JSONObject" %>
<%@ page import="weaver.general.Util" %>
<%@ page import="weaver.hrm.HrmUserVarify" %>
<%@ page import="weaver.hrm.User" %>
<%@ page import="weaver.hrm.resource.ResourceComInfo" %>
<%
    JSONObject jsonData = new JSONObject();
    User user = HrmUserVarify.getUser(request, response);
    String userid = user.getUID() + "";
    try {
        ResourceComInfo resourceComInfo = new ResourceComInfo();
        String userId = Util.null2String(resourceComInfo.getWorkcode(userid));
        //String ssourl = "https://uat.maycur.com/sso";测试
        //String entCode = "EC3RDMXYW96AMD";测试
        //String ssoSecret = "EC3RDMXYW96AMD:YZFhXH0yyj8xPI1W34OJeUdxaczsPpkB";测试
        String ssourl = "https://www.maycur.com/sso";
        String entCode = "EC3O712STOTMPI";
        String ssoSecret = "EC3BGYL7N8ALO1:5bdKFAMSWmclPc2UsxYlXL4Eq0ELuUTm";//该秘钥获取路径“设置-安全设置-系统安全策略-SSO”（若无此入口，需项目经理在boss系统开通相关许可）
        long timestamp = System.currentTimeMillis();
        String ssoToken = DigestUtil.sha256Hex((ssoSecret + ":" + userId + ":" + timestamp).getBytes());
        String url = ssourl+"?entCode=" + entCode + "&userId=" + userId + "&timestamp=" + timestamp + "&token=" + ssoToken +
                "&ssoMode=sso&language=zh&url=";
        jsonData.put("tokenUrl", url);
    } catch (Exception e) {
        e.printStackTrace();
    }
    out.print(jsonData.toJSONString());
%>
